﻿using Domain.Entity;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EfCore.Configers
{
    public class UserConfigers
    {
        public void Configure(EntityTypeBuilder<User> builder)
        {
               // 指定表名
        builder.ToTable(nameof(User));

        // 配置主键
        builder.HasKey(e => e.UId);

        // 配置列 UName 的最大长度为 20
        builder.Property(e => e.UName)
               .HasMaxLength(20)
               .IsRequired(); // 假设用户名是必需的

        // 配置其他列
        builder.Property(e => e.UTrueName)
               .HasMaxLength(50);

        builder.Property(e => e.UPassWord)
               .HasMaxLength(50)
               .IsRequired(); // 假设密码是必需的

        }
    }
}
